Skip to content

Add ~L, ~E, and ~e sigils for EEx and LiveView #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2020
Merged

Add ~L, ~E, and ~e sigils for EEx and LiveView #454

merged 3 commits into from
Jun 12, 2020

Conversation

jsmestad
Copy link
Contributor

@jsmestad jsmestad commented May 30, 2020

I think this is all that is needed.

Any idea how I could get highlighting to work inside the sigil by something like web-mode ?

@axelson
Copy link
Contributor

axelson commented May 30, 2020

Hmm, shouldn't we add support for ~E as well? Unfortunately I'm not sure about how or if we could use web-mode to use HTML-based syntax within an Elixir file.

@jsmestad
Copy link
Contributor Author

jsmestad commented Jun 1, 2020

Hmm, shouldn't we add support for ~E as well? Unfortunately I'm not sure about how or if we could use web-mode to use HTML-based syntax within an Elixir file.

I wonder if we can look at what org-babel does to activate syntax highlighting on a particular region and see if we can duplicate that functionality?

@jsmestad
Copy link
Contributor Author

jsmestad commented Jun 1, 2020

Asking around I found out we can maybe use polymode for this.

I was also told that org-babel uses a separate buffer to render the block of code and then redirects the drawing to the main buffer. (TIL)

@jsmestad
Copy link
Contributor Author

jsmestad commented Jun 5, 2020

@axelson any chance we could get this merged in? I think it may also need a test?

@victorolinasc
Copy link
Contributor

I am of the unpopular opinion that we shouldn't add anything related to Phoenix or Ecto or Absinthe or any other libraries. I understand this widely used but I don't think it belongs on this repo specifically.

I believe though that this is a common issue since JSX became more popular (just my opinion) that Emacs had to deal with many modes simultaneously. Also my opinion that polymode or other alternatives might be better here as pointed by @jsmestad .

As you've guessed, these are just opinions as I am not using these tools now. Fell free to totally ignore me here :)

@jsmestad
Copy link
Contributor Author

jsmestad commented Jun 5, 2020

@victorolinasc I hear what you are saying as it can be seen as bloat for those that do not make use of Phoenix and/or LiveView. However, the alternative of having distinct packages for elixir-mode and then some sort of phoenix-mode that extends it could be difficult to maintain given multiple major modes cannot really run together.

Is there an approach you've seen that would achieve a happy medium? I am no expert on Emacs major modes so I don't mean to "poke the bear" if I missed anything 🤲


For polymode, I would like to write something so for any sigil you can run a second major mode (not only for LiveView sigils). I have a POC working for LiveView, but I could see adding the ability for folks to enable say flyspell in binary sigils

@victorolinasc
Copy link
Contributor

I think you are already much more enlightened than myself on the subject @jsmestad .

Polymode seems to me the way to go here. We can't have two major modes assigned to the same buffer (as far as I can tell...).

@axelson
Copy link
Contributor

axelson commented Jun 5, 2020

@jsmestad I'm still of the opinion that we should add e and E as well. A test would be great as (especially if a similar one already exists). Would polymode be something we add directly to emacs-elixir? Or would that be a solution that users need to add to their own configuration?

@victorolinasc I definitely hear what you're saying about not bloating emacs-elixir with phoenix/ecto/etc related code, but I'm not sure that's viable in practice since it would require a significant amount of work to maintain parallel major modes to support each of those.

@Trevoke any thoughts on this PR?

@jsmestad
Copy link
Contributor Author

jsmestad commented Jun 5, 2020

@axelson yeah we can add those as well.

I did have success getting polymode to work with LiveView templates. I put up a blog post with the code snippet to try it out. Could you give it a spin and see how if it works for you?

@axelson
Copy link
Contributor

axelson commented Jun 5, 2020

Oooh, I'll take a look at the blog post!

@jsmestad
Copy link
Contributor Author

@axelson did you give it a try?

Also I think we can merge in this sigil thing as-is, no?

@jsmestad
Copy link
Contributor Author

jsmestad commented Jun 12, 2020

I looked through the test files and can confirm that not every sigil is tested, besides one set that was to protect against a bug reported in issue #23

@axelson I added ~E, and ~e support

This should be good to merge. 👍

@jsmestad jsmestad changed the title Add ~L LiveView sigil Add ~L, ~E, and ~e sigils for EEx and LiveView Jun 12, 2020
Copy link
Contributor

@axelson axelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding in ~e and ~E. ❤️

@axelson axelson merged commit 670098a into elixir-editors:master Jun 12, 2020
@jsmestad jsmestad deleted the patch-1 branch June 12, 2020 16:29
axelson pushed a commit to elixir-lsp/vscode-elixir-ls that referenced this pull request Jun 22, 2020
* Fix auto-closing quotes for heredocs

Add triple double quotes (`"""`) as an auto-closing pair in the Elixir
language configuration to prevent extra quotes from being inserted when
starting a heredoc string.

* add auto-closing pairs for sigils

- add auto-closing pairs for triple double quotes with sigils
- since adding those auto closing pairs breaks single double quote
  pairs, add pairs for single double quotes with sigils as well
- the sigil list is from
  elixir-editors/emacs-elixir#454
J3RN pushed a commit to J3RN/emacs-elixir that referenced this pull request Apr 24, 2021
* remove legacy io_request handlers

we don't support OTP < R15B

* rescue MatchError in :int calls

Fixes elixir-editors#455

* make output device better conform to erlang I/O protocol

see https://erlang.org/doc/apps/stdlib/io_protocol.html for details

* return WireProtocol.send error to the caller

no need to IO.warn if write fails

* we are redirection stderr to stdout, use stdout as underlying device

* inspect error

* monitor debugged processes

add test for mix task exit
Fixes elixir-editors#454

* avoid debugger crashes when handling requests for no longer existing thread, frame and variable ids

Fixes elixir-editors#452

* add test

* forbid changes of underlying device opts

* refactor and add tests coverage to invalid requests

* Map.pop! is available since elixir 1.10

* run formatter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants